<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
</head>
<body class="hold-transition login-page">
<div class="login-box">
  <div class="login-logo">
    <a href="#"><b>后台管理系统</b></a>
  </div>
  <!-- /.login-logo -->
  <div class="login-box-body">
    <p class="login-box-msg">&nbsp;</p>

    <form method="post">
     	<input type="text" class="form-control"  name="loginName">
     	<br/>
     	<input type="password" class="form-control" placeholder="Password" name="password">
     	<br/>
     	<input type="text" class="form-control" placeholder="验证码" name="captchaCode"><img src="/captcha" id="captchaImg" onclick="changeCaptcha();">
        <button type="button" onclick="doLogin();">登录</button>
    </form>

    <a href="#">忘记密码？</a><br>

  </div>
</div>

<script type="text/javascript" src="/plugins/jquery/1.11.3/jquery.min.js"></script>
<script>
	function changeCaptcha(){
		$("#captchaImg").attr("src","/captcha?t="+new Date().getTime());
	}
	
  	function doLogin(){
	  $.ajax({
		  type:'get',
		  url:'/admin/login/action',
		  data:$("form").serialize(),
		  success:function(data){
			  if(data.code=="0"){
				  window.location.href='/admin';
			  }else if(data.code=="3"){
				  alert("验证码错误！");
				  changeCaptcha();
			  }
			 
		  }
	  });
  }
</script>
</body>
</html>
